package org.example.methodreference;

import java.util.function.BiPredicate;
import java.util.function.Function;

public class Java8MethodReference3a {
    public static void main(String[] args) {
        int result1 = payOneArgument("mlyong", s -> s.length());
        System.err.println(result1);
        int result2 = payOneArgument("mkyong",String::length);
        System.err.println(result2);

        boolean result3 = payTwoArgument("mkyong", "y", (s, s2) -> s.contains(s2));
        System.err.println(result3);
        boolean result4 = payTwoArgument("mkyong","y",String::contains);
        System.err.println(result4);

        boolean result5 = payTwoArgument("mkyong","1",(s1,s2) -> s1.startsWith(s2));
        System.err.println(result5);
        boolean result6 = payTwoArgument("mkyong","m",String::startsWith);
        System.err.println(result6);

    }

    static <R> R payOneArgument(String s1, Function<String,R> func){
        return func.apply(s1);
    }

    static boolean payTwoArgument(String s1, String s2, BiPredicate<String,String> func){
        return func.test(s1,s2);
    }
}
